#include  <stdio.h>
void ReadData(int a[], int n);
void PrintData(int a[], int n);
void MaxMinExchang(int a[], int n);
int main() 
{  	      	
    int a[10], n;
    printf("Input n(n<=10):\n");
    scanf("%d", &n);
    printf("Input %d numbers:\n", n);
    ReadData(a, n);//1
    MaxMinExchang(a, n);//1
    printf("Exchange results:");
    PrintData(a, n);//1
    return 0;
}  	      	
void ReadData(int a[], int n) 
{  	      	
    int i;
    for (i = 0; i < n; i++) //1
    {  	      	
        scanf("%d", &a[i]);
    }
}  	      	
void PrintData(int a[], int n) {  	      	
    int i;
    for (i = 0; i < n; i++)//1
    {  	      	
        printf("%5d", a[i]);//1
    }
    printf("\n");//1
}  	      	
void MaxMinExchang(int a[], int n) 
{  	      	
    int maxValue = a[0], minValue = a[0], maxPos = 0, minPos = 0;//1
    int i, temp;
    for (i = 1; i < n; i++) //1
    {  	      	
        if (a[i] > maxValue) //1
        {  	      	
            maxValue = a[i];//1
            maxPos = i;//1
        }
        if (a[i] < minValue) //1
        {  	      	
            minValue = a[i];
            minPos = i;
        }
    }
    temp = a[maxPos];//1
    a[maxPos] = a[minPos];//1
    a[minPos] = temp;//1
}  	      